{% extends "zato/index.html" %}

{% block html_title %}KVDB translate{% endblock %}

{% block "extra_css" %}
{% endblock %}

{% block "extra_js" %}

    {% comment %} Common JS {% endcomment %}
    <script nonce="{{ CSP_NONCE }}" type="text/javascript" src="/static/js/common.js"></script>

    <script nonce="{{ CSP_NONCE }}" type="text/javascript" src="/static/js/kvdb/data_dict/translation-common.js"></script>
    <script nonce="{{ CSP_NONCE }}" type="text/javascript" src="/static/js/kvdb/data_dict/translation-translate.js"></script>

{% endblock %}

{% block "content" %}

<h2 class="zato">Data dictionaries : Translations : Translate</h2>

{% if not zato_clusters %}
    {% include "zato/no-clusters.html" %}
{% else %}

    <div id="user-message-div" style='display:none'><pre id="user-message" class="user-message"></pre></div>

{% include "zato/search-form.html" with page_prompt="Show the form"%}

{% if cluster_id %}
<div class='page_prompt' style="clear:left">
    <a href="{% url "kvdb-data-dict-dictionary" %}?cluster={{ cluster_id }}" class="common">Dictionaries</a>
    <a href="{% url "kvdb-data-dict-translation" %}?cluster={{ cluster_id }}" class="common">Translations</a>
    <a href="{% url "kvdb-data-dict-impexp" %}?cluster={{ cluster_id }}" class="common">Import/export</a>
    <br/>
    <a href="{% url "kvdb-data-dict-translation-translate" %}?cluster={{ cluster_id }}" class="common current">Translate</a>
</div>

<div id="markup">
<form novalidate action=".?cluster={{ cluster_id }}" method="post" id="translate-form">
{% csrf_token %}
    <table id="data-table">

        <tr>
            <td style="width:7%">System1</td>
            <td style="width:43%">{{ translate_form.system1 }}</td>
            <td style="width:7%">Key1</td>
            <td style="width:43%">{{ translate_form.key1 }}</td>
        </tr>
        <tr>
            <td>Value1</td>
            <td colspan="3">{{ translate_form.value1 }}</td>
        </tr>
        <tr>
            <td>System2</td>
            <td>{{ translate_form.system2 }}</td>
            <td>Key2</td>
            <td>{{ translate_form.key2 }}</td>
        </tr>

        <tr>
            <td colspan="4" style="text-align:right;padding-right:1%">
                <input type="hidden" id="cluster_id" name="cluster_id" value="{{ cluster_id }}" />

                <input type="hidden" id="postback_system1" name="postback_system1" value="{{ postback.system1 }}" />
                <input type="hidden" id="postback_key1" name="postback_key1" value="{{ postback.key1 }}" />
                <input type="hidden" id="postback_value1" name="postback_value1" value="{{ postback.value1 }}" />
                <input type="hidden" id="postback_system2" name="postback_system2" value="{{ postback.system2 }}" />
                <input type="hidden" id="postback_key2" name="postback_key2" value="{{ postback.key2 }}" />

                <input type="submit" value="Translate" />
            </td>
        </tr>

{% if show_translation %}
        <tr>
            <td colspan="4" class='inline_header'>Value2</td>
        </tr>
        <tr>
            <td colspan="4"><pre>{{ translation_result.value2|default:'(No such translation)' }}</pre></td>
        </tr>
        <tr>
            <td colspan="4" class='inline_header'>repr</td>
        </tr>
        <tr>
            <td colspan="4">{{ translation_result.repr|default:'(None)' }}</td>
        </tr>
        <tr>
            <td colspan="4" class='inline_header'>Hex</td>
        </tr>
        <tr>
            <td colspan="4">{{ translation_result.hex|default:'(None)' }}</td>
        </tr>
        <tr>
            <td colspan="4" class='inline_header'>SHA1</td>
        </tr>
        <tr>
            <td colspan="4">{{ translation_result.sha1|default:'(None)' }} </td>
        </tr>
        <tr>
            <td colspan="4" class='inline_header'>SHA256</td>
        </tr>
        <tr>
            <td colspan="4">{{ translation_result.sha256|default:'(None)' }}</td>
        </tr>
{% endif %}
    </table>
        </form>
</div>

{% endif %}
{% endif %}


{% endblock %}
